import 'package:flutter_fronter_service/generated/json/base/json_convert_content.dart';
import 'package:flutter_fronter_service/model/goods_detail_entity.dart';
import 'package:flutter_fronter_service/model/properties_entity.dart';

import 'package:flutter_fronter_service/model/sku_entity.dart';


GoodsDetailEntity $GoodsDetailEntityFromJson(Map<String, dynamic> json) {
  final GoodsDetailEntity goodsDetailEntity = GoodsDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsDetailEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    goodsDetailEntity.name = name;
  }
  final String? picture = jsonConvert.convert<String>(json['picture']);
  if (picture != null) {
    goodsDetailEntity.picture = picture;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    goodsDetailEntity.description = description;
  }
  final int? price = jsonConvert.convert<int>(json['price']);
  if (price != null) {
    goodsDetailEntity.price = price;
  }
  final String? descPictures = jsonConvert.convert<String>(
      json['descPictures']);
  if (descPictures != null) {
    goodsDetailEntity.descPictures = descPictures;
  }
  final List<dynamic>? mainPictures = (json['mainPictures'] as List<dynamic>?)
      ?.map(
          (e) => e)
      .toList();
  if (mainPictures != null) {
    goodsDetailEntity.mainPictures = mainPictures;
  }
  final List<PropertiesEntity>? propList = (json['propList'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<PropertiesEntity>(e) as PropertiesEntity)
      .toList();
  if (propList != null) {
    goodsDetailEntity.propList = propList;
  }
  final List<SkuEntity>? skuList = (json['skuList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<SkuEntity>(e) as SkuEntity).toList();
  if (skuList != null) {
    goodsDetailEntity.skuList = skuList;
  }
  return goodsDetailEntity;
}

Map<String, dynamic> $GoodsDetailEntityToJson(GoodsDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['picture'] = entity.picture;
  data['description'] = entity.description;
  data['price'] = entity.price;
  data['descPictures'] = entity.descPictures;
  data['mainPictures'] = entity.mainPictures;
  data['propList'] = entity.propList.map((v) => v.toJson()).toList();
  data['skuList'] = entity.skuList.map((v) => v.toJson()).toList();
  return data;
}

extension GoodsDetailEntityExtension on GoodsDetailEntity {
  GoodsDetailEntity copyWith({
    int? id,
    String? name,
    String? picture,
    String? description,
    int? price,
    String? descPictures,
    List<dynamic>? mainPictures,
    List<PropertiesEntity>? propList,
    List<SkuEntity>? skuList,
  }) {
    return GoodsDetailEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..picture = picture ?? this.picture
      ..description = description ?? this.description
      ..price = price ?? this.price
      ..descPictures = descPictures ?? this.descPictures
      ..mainPictures = mainPictures ?? this.mainPictures
      ..propList = propList ?? this.propList
      ..skuList = skuList ?? this.skuList;
  }
}